package com.meirimoney.app;

import java.util.Hashtable;

import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import cn.immob.sdk.ImmobView;
import cn.immob.sdk.LMAdListener;

public class ImmobAdWall extends BaseActivity  implements LMAdListener
{
	/**
	 * 力美广告墙布局
	 */
	private LinearLayout immobWall = null;

	/**
	 * 力美内容
	 */
	private ImmobView adView;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.mrm_immob_wall);
		this.initializeOffersWall();
	}

	/**
	 * 初始化力美积分墙
	 */
	private void initializeOffersWall()
	{
		this.immobWall = (LinearLayout) this.findViewById(R.id.immobWall);		
		this.adView = new ImmobView(this, "c28df921f33df2e0e6e994a4b3a99480");
		
		Hashtable<String, String> userProperties = new Hashtable<String, String>();          
		userProperties.put("accountname",this.getUser().getUserId());  
		this.adView.setUserInfo(userProperties);
		
		this.adView.setAdListener(this);
		LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.MATCH_PARENT);
		this.adView.setLayoutParams(params);
		this.immobWall.addView(adView);
	}

	@Override
	protected void onDestroy()
	{
		super.onDestroy();
		if (this.adView != null)
		{
			this.adView.destroy();
		}
	}

	@Override
	public void onAdReceived(ImmobView view)
	{
		if(null!=view)
		{
			this.immobWall.removeViewAt(0);
			view.display();
		}
	}

	@Override
	public void onDismissScreen(ImmobView arg0)
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onFailedToReceiveAd(ImmobView arg0, int arg1)
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onLeaveApplication(ImmobView arg0)
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onPresentScreen(ImmobView arg0)
	{
		// TODO Auto-generated method stub
		
	}
}
